{% extends "imagestore/base.html" %}
{% load i18n %}
{% load thumbnail %}
{% load tagging_tags %}

{% block title %}
    {% trans "Image" %} - {{ image.title }}
{% endblock %}

{% block imagestore-breadcrumb %}
    {% if view_user and IMAGESTORE_SHOW_USER %}
        <li class='scope-view-user'><a href="{% url 'imagestore:user-images' username=view_user %}">{% trans "User" %}: {{ view_user }}</a> <span class="divider">/</span></li>
    {% endif %}
    {% if album %}
        <li class='scope-album'><a href="{{ album.get_absolute_url }}">{% trans "Album" %}: {{ album.name }}</a> <span class="divider">/</span></li>
    {% endif %}
    {% if tag %}
        <li class='scope-tag'><a href="{% url 'imagestore:tag' tag=tag %}">{% trans "Tag" %}: {{ tag }}</a> <span class="divider">/</span></li>
    {% endif %}
    <li>
        {% if image.title %}
            {{ image.title }}
        {% else %}
            {{ image.id }}
        {% endif %}
    </li>
{% endblock %}

{% block imagestore-info %}
    <div class='user-info'>
    {% if IMAGESTORE_SHOW_USER %}
        {% with user=image.user %}
            {% include "imagestore/user_info.html" %}
        {% endwith %}
    {% endif %}
    </div>
{% endblock %}

{% block content %}
        {% if image.title %}<h1>{{ image.title }}</h1>{% endif %}
        {% if album or tag or view_user %}
            <h2>
                    {% include "imagestore/image-scope.html" %}
            </h2>
        {% endif %}
        <div class="image-description">
            {{ image.description }}
        </div>
        <div id="image-view">
            <div class="navigation">
                {% if previous %} <a class="previous-link" href="
                {% with previous as image %}
                    {% include "imagestore/image-href.html" %}
                {% endwith %}
                ">← {% trans "previous image" %}</a> {% endif %}
                {% if next %} <a class="next-link" href="{% with next as image %}
                    {% include "imagestore/image-href.html" %}
                {% endwith %}">{% trans "next image" %} →</a> {% endif %}
            </div>
            {% thumbnail image.image "800x800" as full_im %}
                <img class="preview" {% if image.title %} alt="{{ image.title }}" {% endif %} src="{{ full_im.url }}">
            {% endthumbnail %}
        </div>
{% endblock content %}

{% block controls %}
    {% if request.user == image.user or perms.imagestore.moderate_images %}
        <li><a href="{% url 'imagestore:update-image' image.id %}">{% trans "Edit info" %}</a></li>
        <li><a href="{% url 'imagestore:delete-image' image.id %}">{% trans "Delete image" %}</a></li>
    {% endif %}
{% endblock %}

{% block imagestore-related %}

     <div class="tagging">
            <h2>{% trans "Tags" %}</h2>
            {% tags_for_object image as itags %}
            {% for tag in itags %}
                <a href="{% url 'imagestore:tag' tag.name %}">{{ tag.name }}</a>
            {% endfor %}
     </div>
     {% if image.place %}
         <div class='place'>
            <h2>{% trans "Place" %}</h2>
            <a href="{{ image.place.get_absolute_url }}">{{ image.place.name }} →</a>
         </div>
     {% endif %}
{% endblock %}
